package io;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * 对象反序列化
 *
 */

public class OISDemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        FileInputStream fis = new FileInputStream("person.obj");
        ObjectInputStream ois = new ObjectInputStream(fis);
        /*
        反序列化可能抛出以下异常





         */


        //java.io.InvalidClassException
        Person P = (Person)ois.readObject();
        System.out.println(P);

        ois.close();

    }
}
